var qqcs;
var mc;
var je;

var data1;
var data2;

$(function () {
    $("#main").height($(window).height()-1);
    qqcs = {};
    $.ajax({
        url: "/portal/query/query13/queryData.do",
        data: qqcs,
        type: "post",
        timeout: sys_timeout,
        dataType: "json",
        async: false,
        error: function (XMLHttpRequest, textStatus) {
        },
        success: function (respText) {
            if (checkResponse(respText)) {
                var data = respText.repData.data;
                if (null == data || 0 == data.length) {
                    data1 = [];
                    data2 = [];
                } else {
                    data1 = [
                        {type: 'max', name: '最大值'},
                        {type: 'min', name: '最小值'}
                    ];
                    data2 = [{type: 'average', name: '平均值'}];
                }
                mc = [];
                je = [];
                for (var i = 0; i < data.length; i++) {
                    mc.push(data[i].mc);
                    je.push(data[i].je);
                }
                require.config({
                    paths: {
                        echarts: echarts2_dist_url
                    }
                });
                require(
                    [
                        'echarts',
                        'echarts/chart/line',
                        'echarts/chart/bar'
                    ],
                    function (ec) {
                        var myChart = ec.init(document.getElementById('main'));
                        window.onresize = function () {
                            if (myChart) {
                                myChart.resize();
                            }
                        };
                        option = {
                            tooltip: {
                                trigger: 'axis'
                            },
                            calculable: true,
                            xAxis: [
                                {
                                    type: 'category',
                                    boundaryGap: false,
                                    data: mc,
                                    // axisLabel: {
                                    //     interval: 0,
                                    //     rotate: 40
                                    // }
                                }
                            ],
                            yAxis: [
                                {
                                    type: 'value',
                                    axisLabel: {
                                        formatter: '{value} 万元'
                                    }
                                }
                            ],
                            grid: {
                                x: '80',
                                y: '60',
                                x2: '60',
                                y2: '30'
                            },
                            series: [
                                {
                                    name: '税收收入',
                                    type: 'line',
                                    data: je,
                                    markPoint: {
                                        data: data1
                                    },
                                    markLine: {
                                        data: data2
                                    }
                                }
                            ]
                        };
                        myChart.setOption(option);
                    }
                );
            }
            else {
                innerToast.warn(respText.msg);
            }
        }
    });

});